<template>
  <div>
    <myheader/>
    <h1>展示我的文件列表</h1>
    <table>
      <tr>
        <td>文件</td>
        <td>图片</td>
        <td>操作</td>
      </tr>
      <tr v-for="i in list_pic">
        <td>{{i.name}}</td>
        <td><img :src="i.url" alt="" width="100px" height="80px"></td>
        <td>
          <button @click="del_file(i.name)">删除</button></td>
      </tr>
    </table>

  </div>
</template>

<script>
import myheader from "../myheader";

export default {
  name: "piclist",
  data() {
    return{
      list_pic:[],
      userid:localStorage.getItem('userid')
    }
  },
  methods:{
    //获取文件
    getfile(){
      this.$axios.get('users/getFiles/?userid='+this.userid)
      .then(res=>{
        this.list_pic = res.data.list
      })
    },
    del_file(name){
      this.$axios.delete('users/getFiles/?userid='+this.userid +'&filename='+name)
      .then(res=>{
        if(res.data.code==200){
          alert('删除成功')
          this.getfile()
        }
      })
    }
  },
  mounted() {
    this.getfile()
  },
  components:{
    'myheader':myheader
  }
}
</script>

<style scoped>

</style>
